package com.liang.maogouyuyin.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import com.liang.maogouyuyin.databinding.FragmentInstructionBinding
import com.liang.maogouyuyin.ui.adapter.InstructionAdapter

class InstructionFragment: Fragment() {
    private lateinit var binding: FragmentInstructionBinding

    private lateinit var adapter: InstructionAdapter

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentInstructionBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        initView()
    }

    private fun initView() {
        binding.instructionRecyclerview.layoutManager = GridLayoutManager(requireContext(), 2)
        adapter = InstructionAdapter(requireContext())
        binding.instructionRecyclerview.adapter = adapter
    }

    fun setDog(isDog: Boolean) {
        adapter.setDog(isDog)
    }
}